package com.yuba.front.event;

import lombok.Data;

import java.io.Serial;
import java.io.Serializable;

@Data
public class UpdatePostsEvent implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    private Long postsId;

    /**
     * 点赞或取消点赞
     * 收藏取消收藏
     * 评论数量增加或减少
     */
    private String type;

    private Boolean plusFlag;

    private Integer num;

    public static UpdatePostsEvent build(Long postsId, String type, Boolean plusFlag, Integer num) {
        UpdatePostsEvent event = build(postsId, type, plusFlag);
        event.setNum(num);
        return event;
    }

    public static UpdatePostsEvent build(Long postsId, String type, Boolean plusFlag) {
        UpdatePostsEvent event = new UpdatePostsEvent();
        event.setPostsId(postsId);
        event.setType(type);
        event.setPlusFlag(plusFlag);
        return event;
    }
}
